package cn.tedu.egmybatis1.mapper;

import cn.tedu.egmybatis1.pojo.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * @author tune_the last
 * @date 2025/11/7 - 19:10
 */
@Mapper
public interface ProductMapper {

    @Insert("INSERT INTO product(title, price, stock) VALUES (#{title}, #{price}, #{stock})")
    int insertProduct(Product product);

    @Delete("DELETE FROM product WHERE id = #{id}")
    int deleteProduct(Integer id);

    @Update("UPDATE product SET title = #{title}, price = #{price}, stock = #{stock} WHERE id = #{id}")
    int updateProduct(Product product);
}
